package com.lsq.lwf.common.xmlparse;

import java.io.File;
import java.util.Iterator;
import org.dom4j.Element;

import com.lsq.lwf.common.xmlparse.base.BaseXml;

public class SqlXmlParse extends BaseXml {


	public SqlXmlParse(File file) {
		super(file);

		Element rootElement = doc.getRootElement();

		String namespace = rootElement.attribute("name").getText().trim();
		
		parseSql(rootElement);

		sqlNamespaceMap.put(namespace, sqlMap);
		
	}

	private void parseSql(Element rootElement) {
		@SuppressWarnings("unchecked")
		Iterator<Element> eIter = rootElement.elementIterator();

		while (eIter.hasNext()) {
			Element childElement = eIter.next();
			String name = childElement.attribute("name").getText().trim();
			String value = childElement.getTextTrim();
			sqlMap.put(name, value);
		}
	}

}
